package com.acme.bankapp.server.command;

import com.acme.bankapp.dal.ClientFeedDAO;
import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.client.Client;
import com.acme.bankapp.service.BankService;

public class AddClientCommand extends BankCommand {

	public AddClientCommand(Bank bank, String arg) {
		super(bank, arg);
	}

	@Override
	public String execute() {
		try {
			Client client = ClientFeedDAO.createClientFromCSV(arg);
			BankService.addClient(bank, client);
		} catch (Exception e) {
			return formatError(e.getMessage());
		}
		return "client was successfully added";
	}
	
}
